package com.shujia.wyh.day11;

import java.io.File;
import java.io.FilenameFilter;

/*
    文件名称过滤器: FilenameFilter

 */
public class FilenameFilterDemo1 {
    public static void main(String[] args) {
        File file = new File("E:\\");
        File[] files = file.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
//                return true;
                File file1 = new File(dir, name);
                return file1.isFile() && file1.getName().endsWith("jpg");
            }
        });


        for (File file1 : files) {
            System.out.println(file1.getName());
        }
    }
}
